package com.isoft.systemprovidor.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.isoft.systemprovidor.bean.ResponseData;
import com.isoft.systemprovidor.bean.ResultCode;
import com.isoft.systemprovidor.dao.EleSignature_Dao;
import com.isoft.systemprovidor.entity.EleSignature;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * 电子签章表
 * **/
@Service
@Slf4j
public class EleSignature_Service {
    @Autowired
    EleSignature_Dao eleSignature_dao;

    /*我的审核验证电子签章密码*/
    public ResponseData verifyPassword(String password){
        ResponseData responseData = new ResponseData();
        if (password.isEmpty()||null==password){
            log.info("电子签章为空");
            responseData.setErrorCode(ResultCode.PARAM_IS_BLANK.getCode());
            responseData.setMsg(ResultCode.PARAM_IS_BLANK.getMessage());
            return responseData;
        }
        QueryWrapper wrapper = new QueryWrapper<>();
        wrapper.eq("password",password);
        wrapper.eq("type","审核审批");
        //验证密码持久操作,
        //如果eleSignature为空,则验证失败
        if (null==eleSignature_dao.selectOne(wrapper)){
            log.info("电子签章验证失败");
            responseData.setErrorCode(ResultCode.ACCESS_DENIED.getCode());
            responseData.setMsg(ResultCode.ACCESS_DENIED.getMessage());
            return responseData;
        }
        //验证成功  构造返回Controller 的结果
        log.info("电子签章验证成功");
        responseData.setErrorCode(ResultCode.SUCCESS.getCode());
        responseData.setMsg(ResultCode.SUCCESS.getMessage());
        return responseData;
    }
}
